﻿Imports System.Data.OleDb
Imports DAO
Imports DTO
Public Class HocSinhBUS
#Region "LayBangHS"
    Public Function LayBangHS() As DataTable
        Dim dao As New HocSinhDAO()
        Return dao.LayBangHS()
    End Function
#End Region

#Region "GioiTinh"
    Public Function DSGioiTinh() As List(Of String)
        Dim dao As New HocSinhDAO()
        Return dao.DSGioiTinh()
    End Function
#End Region

#Region "Them1HocSinh"
    Public Function ThemHS(ByVal hsDTO As HocSinhDTO) As Integer
        Dim sql, sql2 As String
        sql = "select TuoiToiThieu from ThamSo"
        sql2 = "select TuoiToiDa from ThamSo"
        Dim cnn As OleDbConnection = DataProvider.ConnectDB()
        Dim cmd As OleDbCommand
        cmd = New OleDbCommand(sql, cnn)

        'While reader.Read()
        Dim tuoitt, tuoitd As Integer
        tuoitt = Convert.ToInt32(cmd.ExecuteScalar())
        cmd = New OleDbCommand(sql2, cnn)
        tuoitd = Convert.ToInt32(cmd.ExecuteScalar())
        'End While
        Dim tuoi As Integer
        Dim namsinh, namht As Integer
        namsinh = hsDTO.NS.Year()
        namht = Date.Now.Year()
        tuoi = namht - namsinh
        If (tuoi >= 15 And tuoi <= 20) Then
            Dim dao As New HocSinhDAO
            Return dao.ThemHocSinh(hsDTO)
        Else
            Return 0 'them that bai
        End If
    End Function
#End Region
#Region "KTHopLe"
    Public Function KTHopLe(ByVal hsDTO As HocSinhDTO) As Integer
        Dim dao As New HocSinhDAO()
        Return dao.KTHopLe(hsDTO)
    End Function
#End Region
#Region "Them1DongDGView"
    Public Function Them1Dong(ByVal hsDTO As HocSinhDTO) As DataTable
        Dim dao As New HocSinhDAO()
        Return dao.Them1Dong(hsDTO)
    End Function
#End Region
End Class
